package com.longrise.android.byjk.plugins.course.allcourse;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;

import com.longrise.android.byjk.R;
import com.longrise.android.byjk.model.AllCourseParentBean;
import com.longrise.android.byjk.plugins.tabsecond.SecondContract;
import com.longrise.android.byjk.plugins.tabsecond.SecondFragmentPagerAdapter;
import com.longrise.android.byjk.plugins.tabsecond.SecondPresenter;
import com.longrise.common.base.BaseActivity2;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by callxkj on 2017/10/25.
 * 保险医学
 */

public class AllCoursebxyxActivity extends BaseActivity2<SecondPresenter> implements SecondContract.View{
    private TabLayout mTb;
    private ViewPager mVp;
    private List<AllCourseParentBean> mParentBeanList =  new ArrayList<>();


    @Override
    public int getContentViewId(@Nullable Bundle savedInstanceState) {
        return R.layout.fragment_second;
    }

    @Override
    public void initView() {
        mTb = (TabLayout) findViewById(R.id.fragment_second_tablayout);
        mVp = (ViewPager) findViewById(R.id.fragment_second_viewpager);
        setToolbarTitle("保险医学");
    }

    @Override
    public void onToolbarBackClick() {
        finish();
    }

    @Override
    public void initAdapter(List<AllCourseParentBean> parentList) {
        mParentBeanList.clear();
        mParentBeanList.addAll(parentList);

        SecondFragmentPagerAdapter pagerAdapter = new SecondFragmentPagerAdapter(getSupportFragmentManager());
        pagerAdapter.setData(mParentBeanList);
        mVp.setAdapter(pagerAdapter);
        mTb.setupWithViewPager(mVp);
    }
}
